/* @(#)GSOrderEmergencyListAction.java    V0.1
 *
 * Project: GSdevelop
 *
 * Modify Information:
 * =============================================================================
 *   Author       Date       Description
 *   ------------ ---------- ---------------------------------------------------
 *   owen         2006-4-11
 *
 * Copyright Notice:
 * =============================================================================
 *    Copyright (c) 2001-2006 Beijing HiTRUST Technology Co., Ltd. 1808 Room, 
 *        Science & Technology Building, No. 9 South Street, Zhong Guan Cun, 
 *        Haidian District, Beijing ,100081, China All rights reserved.
 *
 *    This software is the confidential and proprietary information of
 *        Beijing HiTRUST Technology Co., Ltd. ("Confidential Information").
 *        You shall not disclose such Confidential Information and shall use it
 *        only in accordance with the terms of the license agreement you entered
 *        into with HiTRUST.
 *
 * Warning:
 * =============================================================================
 * 
 */
package com.hitrust.gs.action;

import java.util.ArrayList;
import java.util.HashMap;

import com.hitrust.gs.bean.GSOperatorBean;
import com.hitrust.gs.business.GSManufactureProcessor;
import com.hitrust.gs.business.GSOrderDeptInfoProcessor;
import com.hitrust.gs.business.GSOrderProcessor;
import com.hitrust.gs.form.GSOrderEmergencyListForm;
import com.hitrust.gs.lib.GSBaseConstants;
import com.hitrust.gs.service.GSBaseAction;
import com.hitrust.gs.service.GSBaseForm;
import com.hitrust.gs.util.page.ResultProcess;
import com.hitrust.gs.vo.GSOrderEmergencyVO;

/**
 * 查询应急采购信息的列表
 */
public class GSOrderEmergencyListAction extends GSBaseAction{

    public String execute(GSBaseForm aForm) throws Exception {
        GSOrderEmergencyListForm tForm = (GSOrderEmergencyListForm)aForm;
        GSOrderEmergencyVO tGSOrderVO=new GSOrderEmergencyVO();
        tGSOrderVO.goodsid=tForm.getGoodsid();          //订货单号
        tGSOrderVO.category=tForm.getCategory();         //类型
        tGSOrderVO.orderStatus=tForm.getOrderStatus();      //订单状态
        tGSOrderVO.manufactureId=tForm.getManufactureId();    //产品编码
        tGSOrderVO.orderDeptId=tForm.getOrderDeptId();      //订货单位
        tGSOrderVO.manufactureName=tForm.getManufactureName();  //产品名称
        tGSOrderVO.concentricityid=tForm.getConcentricityid();  //集中编码
        tGSOrderVO.providerId=tForm.getProviderId();       //供应商
        tGSOrderVO.manufInfo=tForm.getManufInfo();       //产品信息
        tGSOrderVO.firstdate=tForm.getFirstdate();       
        tGSOrderVO.lastdate=tForm.getLastdate();       
        //产品种类
        tGSOrderVO.Manuftype1=tForm.getManuftype1();
        tGSOrderVO.Manuftype2=tForm.getManuftype2();
        tGSOrderVO.Manuftype3=tForm.getManuftype3();
        
       // if(tManuftype1.equals("0")){
        //    tGSOrderVO.manufacturecategory="";
      //  }
       // else if(tManuftype2.equals("0")){
      //      tGSOrderVO.manufacturecategory=tManuftype1;
      //  }
       // else if(tManuftype3.equals("0")){
       //     tGSOrderVO.manufacturecategory=tManuftype2;
       // }
       // else{
       //     tGSOrderVO.manufacturecategory=tManuftype3;
       // }
        
        try{
            GSOrderProcessor tProc = new GSOrderProcessor();
//          取得当前操作员信息
            GSOperatorBean tOperBean = (GSOperatorBean)aForm.getSession().getAttribute(GSBaseConstants.LOGIN);
            //查询当前操作员所能操作订货单位的所有送货地址
            GSOrderDeptInfoProcessor tOrderDeptProc = new GSOrderDeptInfoProcessor();
            HashMap tMap = tOrderDeptProc.getOrderDeptInfoOfOper(tOperBean.getGs_oper_org_id());
            tForm.getRequest().setAttribute("orderdept",tMap);
            //查询当前操作员所能操作的订货单位
            ArrayList tOrg = (ArrayList)tMap.get("organization");
            
            ArrayList tList = tProc.getEmergencyOrderAndDetail(tGSOrderVO,tOrg);
            ResultProcess tRsProc = new ResultProcess();
            tRsProc.setResult(tList);
            tForm.getRequest().setAttribute("order",tRsProc);
            //aForm.getRequest().setAttribute("orderStatus",tForm.orderStatus);
            
            aForm.getRequest().setAttribute("category",tForm.getCategory());
            aForm.getRequest().setAttribute("orderStatus",tForm.getOrderStatus());
    
            
            //GSOperatorBean tOperBean = (GSOperatorBean)aForm.getSession().getAttribute(GSBaseConstants.LOGIN);
           // GSOrderDeptInfoProcessor tOrderDeptInfoProc = new GSOrderDeptInfoProcessor();
            HashMap tMap1 = tOrderDeptProc.getOrderDeptInfoOfOper(tOperBean.getGs_oper_org_id());
            aForm.getRequest().setAttribute("orderdept",tMap1);
            
            //种类等级
            GSManufactureProcessor tGSManufProcessor = new GSManufactureProcessor();
            tGSManufProcessor.getManufactureOfLevel(aForm);
            aForm.getRequest().setAttribute("requery","false");
        }
        catch(Exception e){
            tForm.getRequest().setAttribute("action","A110201.do");
            throw e;
        }      
        
        
        
        return GSBaseConstants.FORWARD_SUCCESS;
    }
}
